]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
search: Do not check for class cancellable state after awaiting
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Mon, 16 Feb 2026 21:11:28 +0000 (22:11 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 17 Feb 2026 14:00:14 +0000 (14:00 +0000)
In an async function, after awaiting, the cancelled state for the
class-tracked cancellable may not respect the actual state of the
cancellable that has been used to perform the call.

Thus, let's use a local variable instead

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4080>

js/ui/search.js

index 7f72a87d25373134e85e8826a4a97f7fa43115a6..76e49bc1e2a1ebf0fea179062814325c55549b38 100644 (file)
@@ -226,11 +226,12 @@ const SearchResultsBase = GObject.registerClass({
             return;
 
         this._cancellable.cancel();
-        this._cancellable = new Gio.Cancellable();
+        const cancellable = new Gio.Cancellable();
+        this._cancellable = cancellable;
 
-        const metas = await this.provider.getResultMetas(metasNeeded, this._cancellable);
+        const metas = await this.provider.getResultMetas(metasNeeded, cancellable);
 
-        if (this._cancellable.is_cancelled()) {
+        if (cancellable.is_cancelled()) {
             if (metas.length > 0)
                 throw new Error(`Search provider ${this.provider.id} returned results after the request was canceled`);
         }